import axios from 'axios'
import {Message} from "element-ui";
import {API} from "@/api/config";
// 创建axios的对象
const request = axios.create({
    baseURL: API,
    contentType: "application/json",
    timeout: 6000
})


// 响应拦截
// 此处可以根据服务器返回的状态码做相应的数据
request.interceptors.response.use(
     (resp) =>{
        if (resp.data.code === 200) {
            return resp;
        } else {
            Message.error(resp.data.msg);
            return Promise.reject(resp.data.msg)
        }

    }
)

export default request;